package com.fc.service.impl;

import java.util.List;

import org.hibernate.Criteria
import org.hibernate.criterion.Projections
import org.hibernate.criterion.Restrictions
import org.springframework.stereotype.Repository
import org.springframework.transaction.annotation.Transactional

import com.fc.service.ActivityGroupService
import com.fc.entities.ActivityGroup

@Repository("activityGroupService")
@Transactional
class ActivityGroupServiceImpl extends BaseServiceImpl<ActivityGroup> implements ActivityGroupService {
	@Override
	List<String> getAllNames() {
		Criteria criteria = currentSession().createCriteria(ActivityGroup.class, "activitygroup").setProjection(Projections.projectionList().add(Projections.property("activitygroup.name")));
		return criteria.list();
	}
	
	ActivityGroup findByName(String name) {
		Criteria criteria = currentSession().createCriteria(ActivityGroup.class);
		ActivityGroup entity = (ActivityGroup) criteria.add(Restrictions.eq("name", name)).uniqueResult();
		return entity;
	}

	@Override
	List<ActivityGroup> findAll() {
		findAll(ActivityGroup.class)
	}
}
